package model;

public class Vote extends PersistentEntity   implements Comparable<Vote>{
  public enum AnswerType {
    A, B
  };
  private AnswerType answer;
  private User user;
  private Integer points=null;

  public Vote(User user,AnswerType answer ) {
    super();
    this.answer = answer;
    this.user = user;
  }

  public Integer getPoints() {
    return points;
  }

  public void setPoints(Integer points) {
    this.points = points;
  }

  public AnswerType getAnswer() {
    return answer;
  }

  public void setAnswer(AnswerType answer) {
    this.answer = answer;
  }

  public User getUser() {
    return user;
  }

  public void setUser(User user) {
    this.user = user;
  }

  @Override
  public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result + ((user == null) ? 0 : user.hashCode());
    return result;
  }

  @Override
  public boolean equals(Object obj) {
    if (this == obj)
      return true;
    if (obj == null)
      return false;
    if (getClass() != obj.getClass())
      return false;
    Vote other = (Vote) obj;
    if (user == null) {
      if (other.user != null)
        return false;
    } else if (!user.equals(other.user))
      return false;
    return true;
  }

  @Override
  public int compareTo(Vote v) {
    return this.user.getName().compareTo(v.user.getName());
  }
}
